
var req = require('../../../utils/token.js');
var app = getApp();
Page({
  data: {
    title:{
      "flag": 2,
      "name": "发布记录"
    },
    winWidth: 0,
    winHeight: 0,
    currentTab: 0,
    //  xiaopiaoInfo: [
    //   { id: 1, money: "小费五元", createTime: "2019-10-10 02:00:00", address: "正大广场五楼" },
    //   { id: 2, money: "小费五元", createTime: "2019-10-10 02:00:00", address: "正大广场五楼" },
    // ],
    // stopInfo: [
    //   { id: 1, addressInfo: "正大广场三楼、购物小票不低于100元", createTimeStop: "2019-10-10 02:00:00" },
    //   { id: 2, addressInfo: "正大广场三楼、购物小票不低于100元", createTimeStop: "2019-10-10 02:00:00" },
    // ]
  },
  onLoad: function () {
    if (app.globalData.userInfo == null || app.globalData.userInfo == '') {
      wx.showToast({
        title: '请先登录',
        icon: "none",
        duration: 1000
      })
      setTimeout(function () {
        wx.switchTab({
          url: '/pages/ticket/personal/personal'    //我的
        });
      }, 1000)
    }
    var that = this;
    that.list();

    /**
     * 获取当前设备的宽高
     */
    wx.getSystemInfo({

      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }

    });
  },

  //  tab切换逻辑
  swichNav: function (e) {

    var that = this;

    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
    that.list();
  },

  bindChange: function (e) {

    var that = this;
    that.setData({ currentTab: e.detail.current });

  },
  list:function(){
    var url='';
    var _this = this;
    var header = req.CreateHeader();
    if (_this.data.currentTab==0){
      url ="ticket/getTicketAll";
    } else if (_this.data.currentTab == 1){
      url = "park/parkInfoAll";
    }
    wx.request({
      url: app.globalData.url + url,
      header: header,
      data:{
        userId: app.globalData.userInfo.uuid
      },
      method:'get',
      success: function (res) {
        console.log(res)
          _this.setData({
            stopInfo:res.data,
            xiaopiaoInfo:res.data
          })
      },
      fail: function (res) {
      }
    })

  }
})